local BaseWnd = require(SCRIPTS_DIR .. ".wnds.BaseWnd");
local AreaText = require(SCRIPTS_DIR .. ".uikits.AreaText");
local TestWnd = class("TestWnd",BaseWnd);
function TestWnd:ctor()
	TestWnd.super.ctor(self);
end


function TestWnd:onOpen()
   mgrs.log:printFuncCall();
    --[[
        local videoPlayer = ccexp.VideoPlayer:create()
        videoPlayer:setPosition(cc.p(display.widthInPixels/2, display.heightInPixels/2))
        videoPlayer:setAnchorPoint(cc.p(0.5, 0.5))
        videoPlayer:setContentSize(cc.size(display.widthInPixels, display.heightInPixels))
        videoPlayer:setFileName("res/test.mp4")
        videoPlayer:setKeepAspectRatioEnabled(true)
        videoPlayer:setFullScreenEnabled(true)
        videoPlayer:setVisible(true)
        self:addChild(videoPlayer)
        videoPlayer:play()
    ]]

    --[[
    self.label:enableUnderLine(true);
--    self.label:setDimensions(150,0);
    self.label:setTouchEnabled(true);
    self.label:addNodeEventListener(cc.NODE_TOUCH_EVENT,function(args)
        print("aaaaaaaaaaaaaaaaaaaaaaaaaaaa");
    end)
    dump(self.label:getContentSize())
	]]


    --[[
    local testBtn = self:clonePrefab("testButton");
    testBtn:setPosition(cc.p(100,100));
    self:addChild(testBtn);


    local text = self:widget("Text_1");
    local areaText = AreaText.new(text);
    areaText:setStr("<div fontcolor=#00ff00 underline=true>helloworldworldworldworldworldworldworldworldworldworldworldworldworldworldworldworldworldworldworld</div><img src='res/test.png' scale=0.5 rotate=90 visible=true />world",true);
    areaText:setClickHandler(function()
        print("AreaText!!!!!!!!!!!!!!!!!");
    end)
	

    local test_text = {
        "<div fontcolor=#ff0000 underline=true>hello</div><div fontcolor=#00ff00 underline=true>hello</div><div fontsize=12 underline=true>你</div><div fontSize=26 fontcolor=#ff00bb underline=true>好</div>ok",
       "<div outline=1,#ff0000 underline=true>hello</div>",
        "<div glow=#ff0000 underline=true>hello</div>",
        "<div shadow=2,-2,0.5,#ff0000 underline=true>world</div>",
        "<div fontcolor=#ff0000 underline=true>hello</div><img src='res/test.png' scale=0.5 rotate=90 visible=true />world",
    }
    for i=1, #test_text do
        local RichLabel = require("richlabel.RichLabel")
        local label = RichLabel.new {
            fontName = "res/msyh.ttf",
            fontSize = 20,
            fontColor = cc.c3b(255, 255, 255),
            maxWidth=200,
            lineSpace=0,
            charSpace=0,
        }
        label:setString(test_text[i])
        label:setPosition(cc.p(380,500-i*30))
        label:playAnimation()
        self:addChild(label)
        label:setTouchEnabled(true);
        label:addNodeEventListener(cc.NODE_TOUCH_EVENT,function(args)
            print("richText!!!!!!!!!!!!!");
        end)
--      label:debugDraw(1)
    end
	

    local num = require("scripts.pubs.RoundNum");
    local x = num.new({num=987,type=2,showPlus=true,cbk = function()
        print("xxxxxxxxxxxxxxxxxxxxx");
    end
    });
--    x:setAnchorPoint(cc.p(0.5,0.5));
    x:setPosition(cc.p(300,100));
    self:addChild(x);

    function LoginWnd:getPreloadResList()
	return {
        Armature={"ani_0027"},
        Png={"background","smallLoading","1","2","3"},
        Plist={"stage"},
        Spine={"knight"}
    };
end

    ]]


    --[[
    local clippingNode = cc.ClippingNode:create();
    clippingNode:setPosition(cc.p(300,300));
    clippingNode:setStencil(cc.Sprite:create(mgrs.res:getPngPath("zhezhao4")));
    clippingNode:setInverted(false);
    clippingNode:setAlphaThreshold(0.5);
	self:addChild(clippingNode);

    local sprite = cc.Sprite:create(mgrs.res:getPngPath("vipGift_2"));
    sprite:setPosition(cc.p(0,-20));
    clippingNode:addChild(sprite);


    local size = clippingNode:getContentSize();
    dump(size);

    local click = self:createClick({targetNode = clippingNode});
    click:clickHandler(function()
        print("aaaaaaa");
    end);

    --]]


    --[[
        local btn = self:widget("button");
	if btn then
		btn:onButtonClicked(function()
			mgrs.hint:showHint("wo shi zhongguo ren");
            mgrs.hint:showHint("wo shi zhongguo ren!!!!!!");
			mgrs.behave:nextBehave(enums.Behave.Hint);
		end);
		btn:onButtonPressed(function()
			printInfo("Clicked!!!!!!!!!!!!!!!!");
		end);
	end

    for i=1,10 do
		mgrs.hint:showMarquee("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbcssssss");
		mgrs.hint:showMarquee("wo shi zhongguo ren !!!!!!!!!!!!!");
	end
	mgrs.behave:nextBehave(enums.Behave.Bulletin);

    mgrs.input:lock(enums.Locker.Test1,1000);
    mgrs.input:lock(enums.Locker.Test1,10000);
    mgrs.overTime:show(enums.OverTime.Test1,5000);
    ]]
    self:setTouchEvent();
end

function TestWnd:setTouchEvent()
    self:setTouchEnabled(true);
    self:addNodeEventListener(cc.NODE_TOUCH_EVENT, function (event)
	    if "began" == event.name then
		    return true;
	    elseif "moved" == event.name then
            
	    elseif "ended" == event.name then
            
	    end
	end)
end

function TestWnd:TestAction()
    mgrs.action:beginAction(self.label):MoveBy(2,cc.p(200,200)):Reverse():ScaleTo(2,0.1):CallFunc(function(node,value)
        print("action end 1   %d",value.value);
    end,{value = 11}):endAction();
    mgrs.action:beginAction(self.btn):MoveBy(2,cc.p(200,200)):ScaleTo(2,0.1):CallFunc(function(node,value)
        print("action end 1   %d",value.value);
    end,{value = 12}):endAction();
end

function TestWnd:onClose()
	
end

function TestWnd:btnClicked()
    mgrs.log:printDebug("!!!!!TestWnd onClose!!!!!");
end



function TestWnd:reqData(handler)
	handler(true);	
end

--[[
function TestWnd:getRelativePosition()
	return {rx = 0.5; ry = 0.5; ox = 0; oy = 0;	};
end
--]]

function TestWnd:getLayer()
	return enums.Layer.Window;
end

function TestWnd:getPreloadResList()
	return {
        Spine={"knight"}
    };
end

function TestWnd:getExclusiveType()
	return 1;
end

function TestWnd:isOpenCloseSoundEnabled()
	return false;
end

function TestWnd:onEnter()
	mgrs.log:printDebug("Wnd:onEnter");
end

mgrs.wnd:registerWnd(enums.Wnd.Test,TestWnd);

